package com.yh.daoimpl;

import com.yh.dao.UserDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

/**
 * @Auther: Liang
 * @Date: 2024/5/15 - 05 - 15 - 18:30
 * @Description: com.yh.daoimpl
 * @version: 1.0
 */
@Repository("userDao")
public class UserDaoImpl implements UserDao {
    //书写jdbcTemplate属性
    @Autowired
    private JdbcTemplate jdbcTemplate;

    public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
        this.jdbcTemplate = jdbcTemplate;
    }

    @Override
    public int updateUsernameByUid(int uid, String username) {
        String sql ="update user set username=? where uid=?";
        return jdbcTemplate.update(sql,username,uid);
    }

    @Override
    public int updatePasswordByUid(int uid, String password) {
        String sql ="update user set password=? where uid=?";
        return jdbcTemplate.update(sql,password,uid);

    }

}
